using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BlogEngine.Core.Providers;
using BlogEngine.Core;

public partial class gallery_deletealbum : System.Web.UI.Page
{
	protected Album album;

	protected void Page_Load(object sender, EventArgs e)
	{
		Guid guid = new Guid(Request.QueryString["AlbumId"]);
		album = Album.GetById(guid);

		Page.Title = Resources.labels.album;

		btnDelete.Click += new EventHandler(btnAlbum_Click);
	}

	#region Event handlers

	/// <summary>
	/// deletes the album
	/// </summary>
	private void btnAlbum_Click(object sender, EventArgs e)
	{
		string albumid = album.Id.ToString();

		album.IsPublished = false;
		album.Save();

		foreach (Photo photo in album.Photos.ToArray())
		{	
			photo.Delete();
			photo.Save();
		}
		
		album.Delete();
		album.Save();
		Response.Redirect("ViewAlbums.aspx");
	}

	#endregion

}
